import asyncio
from autogen_core.models import UserMessage
from autogen_ext.models.openai import OpenAIChatCompletionClient

# 创建OpenAIChatCompletionClient对象-更推荐这种写法
model_client = OpenAIChatCompletionClient(model="deepseek-chat", base_url="https://api.deepseek.com",
                                          api_key="sk-6d775065fa8c405caebed674c125e67e",
                                          model_info={
                                              "vision": False,
                                              "function_calling": False,
                                              "json_output": True,
                                              "family": "unknown",
                                          })


# 使用模型客户端进行交互
async def chat_with_model():
    result = await model_client.create([UserMessage(content="中国的首都是什么?", source="user")])
    print(result.model_dump_json())

if __name__ == '__main__':
    asyncio.run(chat_with_model())